package generator.domain;


/**
 * @ClassName DoubleLock
 * @Description: TODO
 * @Author: Sunny
 * @Create: 2023-06-03 13:31
 * @Version 1.0
 **/
public class DoubleLock {
    //public static void main(String[] args) {
    //    int arr[] = {1, 10, 25, 2, 7};
    //    for (int i = 0; i < arr.length; i++) {
    //        for (int j = 0; j < arr.length - 1 - i; j++) {
    //            if (arr[j] > arr[j + 1]) {
    //                int temp = arr[j];
    //                arr[j] = arr[j + 1];
    //                arr[j + 1] = temp;
    //            }
    //        }
    //    }
    //    for (int i : arr) {
    //        System.out.println(i);
    //    }
    //}

    private static DoubleLock doubleLock;

    private DoubleLock() {

    }

    public static DoubleLock getInstance() {
        if (doubleLock == null) {
            synchronized (DoubleLock.class) {
                if (doubleLock == null) {
                    doubleLock = new DoubleLock();
                }
            }
        }
        return doubleLock;
    }



    public static void main(String[] args) {
        DoubleLock doubleLock = new DoubleLock();
        DoubleLock doubleLock2 = new DoubleLock();
        DoubleLock instance = getInstance();
        DoubleLock instance2 = getInstance();
        System.out.println(instance==instance2);
        System.out.println(doubleLock.equals(doubleLock2));

    }

}